layui.config({
    base: '../../layui/' //此处路径请自行处理, 可以使用绝对路径
}).extend({
    formSelects: 'formSelects-v4'
}).use(['jquery', 'formSelects', 'form','layer'], function () {
    const form = layui.form
        , layer = layui.layer
        , $ = layui.jquery;

    form.on('submit(save)', function (data) {
        const params = data.field;
        params.linuxPath=$("#linuxPath").val()
        submit($, params);
        return false;
    });

    function submit($, params) {
        $.ajax({
            url: '/server/saveContentForTemp',
            data: JSON.stringify(params),
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            type: "PUT",
            success: function (result) {
                layer.msg("保存成功", {icon: 1, time: 1000}, function () {
                    CloseWin();
                })
            }
        })
    }
    $("#close").on('click', function () {
        const index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    });
    //关闭页面
    function CloseWin() {
        // parent.location.reload(); // 父页面刷新
        const index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
        // window.parent.$("input[id='pathName").val($("#linuxPath").val());
        parent.layui.table.reloadData("serverFile")
    }

});

